//package com.ande.bridge.admin.datasource;
//
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.After;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Component;
//
///**
// * 
// * <pre>  
// * <b> AOP 反射设置数据源到TargetDataSource注解中.</b>
// * <b>Author: tianhua.lan@la-inc.cn </b> 
// * <b>date: 2018年5月23日 下午6:30:08   </b> 
// *   ----------------------------------------------------------------------------
// *   ----------------------------------------------------------------------------
// * <pre>
// */
//@Aspect
//@Order(-1)// 保证该AOP在@Transactional之前执行
//@Component
//public class DynamicDataSourceAspect {
//
//    private static final Logger logger = LoggerFactory.getLogger(DynamicDataSourceAspect.class);
//   
//    @Before("@annotation(ds)")
//    public void changeDataSource(JoinPoint point, TargetDataSource ds) throws Throwable {
//        String dsId = ds.name();
//        if (!DynamicDataSourceContextHolder.containsDataSource(dsId)) {
//            logger.error("数据源[{}]不存在，使用默认数据源 > {}", ds.name(), point.getSignature());
//        } else {
//            logger.debug("Use DataSource : {} > {}", ds.name(), point.getSignature());
//            DynamicDataSourceContextHolder.setDataSourceType(ds.name());
//        }
//    }
//
//    @After("@annotation(ds)")
//    public void restoreDataSource(JoinPoint point, TargetDataSource ds) {
//        logger.debug("Revert DataSource : {} > {}", ds.name(), point.getSignature());
//        DynamicDataSourceContextHolder.clearDataSourceType();
//    }
//
//}
